package k2_oop.p2_inheritAndPolymorphic.demo10;

/**
 * 定义一个测试类Test，
 * 编写equalsArea方法测试两个对象的面积是否相等（注意方法的参数类型，利用动态绑定技术）
 * 编写displayGeometricObject方法显示对象的面积（注意方法的参数类型，利用动态绑定技术）
 */
public class TestDemo10 {

    public void equalsArea(GeometricObject obj1,GeometricObject obj2){
        if(obj1.findArea()==obj2.findArea()){
            System.out.println("两个图形的面积相等");
        }else{
            System.out.println("两个图形的面积不等");
        }
    }

    public void displayGeometricObject(GeometricObject obj){
        System.out.println("图形的面积是："+obj.findArea());
    }

    public static void main(String[] args) {

        TestDemo10 demo = new TestDemo10();

        GeometricObject obj1 = new Circle("red",100,2);
        GeometricObject obj2 = new Circle("red",100,3);
        GeometricObject obj3 = new Circle("red",100,4);
        GeometricObject obj4 = new Rectangle("red",100,2,5);
        GeometricObject obj5 = new Rectangle("red",100,3.14,4);
        GeometricObject obj6 = new Rectangle("red",100,7,8);

        demo.displayGeometricObject(obj1);
        demo.displayGeometricObject(obj5);
        demo.equalsArea(obj1,obj5);
    }
}
